#include "stdio.h"
#include "lw_oopc.h"
#include "ctrl.h"
#include "switch.h"

CLASS(Rectangle)
{
	void (*init)(Rectangle*);
	void (*print_perimeter)(Rectangle*);
	double length,width;
};

static void init(Rectangle *t) 
{
	t->length = 10.5;
	t->width = 5.125;
}
static void print_perimeter(Rectangle *t)
{
	printf("p = %f\n",2*(t->length+t->width));
}
CTOR(Rectangle)
	FUNCTION_SETTING(init,init)
	FUNCTION_SETTING(print_perimeter,print_perimeter)
END_CTOR

void main()
{
	CTRL* ctrl = (CTRL*)CTRLNew();
	DoorSwitch *psw = DoorSwitchNew();
	Rectangle *rect = (Rectangle*)RectangleNew();
	ctrl->init(ctrl);
	ctrl->turnOn(ctrl);
	psw->swDown();
	ctrl->turnOff(ctrl);
	psw->swUp();
	rect->init(rect);
	rect->print_perimeter(rect);
	getchar();
	return 0;
}